package com.francesc.bo.borsa.business;

import java.util.Iterator;
import java.util.List;

import com.francesc.bo.borsa.io.IoActions;
import com.francesc.bo.borsa.model.Moviment;
import com.francesc.bo.borsa.model.Valor;

public class Consultes {

	private IoActions ioActions;

	public Consultes(IoActions ioActions) {
		this.ioActions = ioActions;
	}

	public List<Moviment> getMovimentsValor(Valor valor) {
		List<Moviment> it = ioActions.getMovimentsValor(valor);
		for (Moviment moviment : it) {
			System.out.println(moviment);
		}
		return it;
	}

	public Moviment loadUltimMoviment(Valor valor) {
		Moviment m = ioActions.loadUltimMoviment(valor);
		System.out.println(m);
		return m;

	}

	public Iterator<Moviment> getMoviments() {
		Iterator<Moviment> it = ioActions.getMoviments();
		for (; it.hasNext();) {
			System.out.println(it.next());
		}
		return it;
	}
}
